package com.ggboy.item_bank.service.imp;

import com.ggboy.item_bank.beans.User;
import com.ggboy.item_bank.dao.UserDao;
import com.ggboy.item_bank.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;
    @Override
    public User isRegister(String username) {//根据用户名获取该用户的所有信息
        return userDao.checkPhoneNum(username);
    }
    public String addUser(User user) {
        if (userDao.checkPhoneNum(user.getUsername())!=null){//判断用户名是否重名
            return "用户已经存在";
        } else if (userDao.checkPhoneNum3(user.getTeacherId())!=null) {//判断该学号是否已经创建账号
            return "该学号已有用户";
        }else {
            user.setFlag(1);
            userDao.insert(user);
            return null;
        }

    }
}
